<% content_for :left_sidebar do  %>
  <%= render :partial => "layouts/sidebar/xiwenguanli" %>
<% end %>
<%- model_class = Notify -%>
<div class="page-header">
  <h1>新闻线索列表</h1>
</div>

<%= form_tag admins_clues_path,:method => :get do %>
    <table class="search_table">
      <tr>
        <td>稿件类型:
        	 <% if (current_user.admin? )  %>
        	   <%= select_tag :clue_type,options_for_select([['我的稿件',1],['平台稿件',2]],session[:clue_type]) %>
        	   <% else %>
        	    <%= select_tag :clue_type,options_for_select([['我的稿件',1]],session[:clue_type]) %>
        	 <% end %>
        
        </td>
        <td>稿件状态:
          <%= select_tag :check,options_for_select([['--请选择--',nil]] + Clue::CHECK.to_a,params[:check]) %>
        </td>
        	<td>来稿单位:
        	  <%= select_tag(:department, options_from_collection_for_select(@departments, "name", "name"), prompt: '请选择' )   %>
        	</td>
      </tr>
      <tr>
        <td colspan="6">
          <%= select_button %>
          <%= new_button url: new_admins_clue_path,name: '新建线索' %>
        </td>
      </tr>
    </table>
<% end %>

<table class="table table-striped">
  <thead>
    <tr>
      <th>ID</th>
      <th>推送单位</th>
      <th>联系人</th>
      <th>联系电话</th>
      <th>线索状态</th>
      <th>操作</th>
    </tr>
  </thead>
  <tbody>
    <% @clues.each do |clue| %>
      <tr>
        <td><%=  clue.id %></td>
        <td><%=  clue.contribution_units %></td>
        <td><%=link_to clue.linkman, admins_clue_path(clue)   %></td>
        <td><%= clue.phone %></td>
        <td>
          <% if clue.check == 0 %>
              <%= clue.check_text %>
          <% else  %>
              <%= link_to "#{clue.check_text}",admins_clue_path(clue) %>
          <% end %>
        </td>
        <td>
          <% if Clue.can_edit?(clue,current_user) %>
              <%= link_to "编辑",edit_admins_clue_path(clue),:class => 'btn btn-default btn-xs' %>
              <%= link_to "删除",admins_clue_path(clue),
                          :method => :delete,
                          :data => { :confirm => '确定删除?' },
                          :class => 'btn btn-xs btn-danger' %>
          <% end %>
          <% if Clue.can_approve?(clue,current_user) %>
              <%= link_to "审核",admins_clue_path(clue),:class => 'btn btn-info btn-xs' %>
          <% end %>
          <% if clue.check == 0 %>
              <%= link_to "送审",admins_clue_path(clue),:class => 'btn btn-info btn-xs' %>
          <% end %>
        </td>
      </tr>
    <% end %>
  </tbody>
</table>

<div class="count">
  <%= paginate @clues %>
</div>